﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using FireStarterModeller.BO;
using FireStarterModeller.Test.BO;
using FireStarterModeller.UI;
using FireStarterModeller.UI.LookupLists;
using Habanero.Base;
using Habanero.BO;
using Habanero.Faces.Base;
using Habanero.Faces.Win;
using NUnit.Framework;

namespace FireStarterModeller.Test.UI.LookupLists
{
    [TestFixture]
    public class TestBusinessObjectLookupListControl
    {
        [TestFixtureSetUp]
        public void SetupFixture()
        {
            UITestUtils.SetupFixture();
        }

        [SetUp]
        public virtual void SetupTest()
        {
            UITestUtils.SetupTest();
        }

        private static IControlFactory CreateControlFactory()
        {
            return new ControlFactoryWin();
        }

        [Test]
        public void Test_Construct()
        {
            //---------------Set up test pack-------------------
            IControlFactory controlFactory = CreateControlFactory();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(controlFactory);
            //---------------Test Result -----------------------
            Assert.AreSame(controlFactory, businessObjectLookupListControl.ControlFactory);
            Assert.IsInstanceOf(typeof(ILookupListControl), businessObjectLookupListControl);
        }

        [Test]
        public void Test_Construct_WhenNullControlFactorySet_ShouldThrowException()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                new BusinessObjectLookupListControl(null);
                Assert.Fail("expected ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("Value cannot be null", ex.Message);
                StringAssert.Contains("controlFactory", ex.ParamName);
            }
            //---------------Test Result -----------------------
        }

        [Test]
        public void Test_Consturct_ShouldLoadPanelWithAllControls()
        {
            //---------------Set up test pack-------------------
            TestUtilsDMClass.CreateUnsavedValidDMClass();
            TestUtilsDMClass.CreateUnsavedValidDMClass();
            TestUtilsDMClass.CreateUnsavedValidDMClass();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            //---------------Test Result -----------------------
            Assert.AreEqual(1, businessObjectLookupListControl.Controls.Count);
            IPanel panel = TestUtilsShared.AssertIsInstanceOf<IPanel>(businessObjectLookupListControl.Controls[0]);
            Assert.AreEqual(9, panel.Controls.Count);
            AssertAllControlsWereCreated(businessObjectLookupListControl);
            //Assert.AreEqual(3,panel.BusinessObjectCollection.Count);
            //Assert.IsFalse(sortComboBox.Enabled);
            //Assert.IsFalse(ascendingCheckBox.Enabled);
            //Assert.IsFalse(criteriaTextBox.Enabled);
        }

        [Test]
        public void Test_ClassComboBox_WhenSelectedBusinessObjectNull_ShouldDisableSortComboBoxAscendingCheckBoxAndCriteriaTextBox()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            IComboBox classComboBox = TestUtilsShared.AssertIsInstanceOf<IComboBox>(businessObjectLookupListControl.Controls[0].Controls[1]);
            //IComboBox sortComboBox = TestUtilsShared.AssertIsInstanceOf<IComboBox>(businessObjectLookupListControl.Controls[0].Controls[4]);
            ExtendedTextBoxWin sortOrderExtendedTextBox = TestUtilsShared.AssertIsInstanceOf<ExtendedTextBoxWin>(businessObjectLookupListControl.Controls[0].Controls[4]);
            //ICheckBox ascendingCheckBox = TestUtilsShared.AssertIsInstanceOf<ICheckBox>(businessObjectLookupListControl.Controls[0].Controls[7]);
            ITextBox criteriaTextBox = TestUtilsShared.AssertIsInstanceOf<ITextBox>(businessObjectLookupListControl.Controls[0].Controls[7]);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(classComboBox);
            //---------------Execute Test ----------------------
            classComboBox.SelectedItem = null;
            //---------------Test Result -----------------------
            Assert.IsFalse(sortOrderExtendedTextBox.Enabled);
            //Assert.IsFalse(ascendingCheckBox.Enabled);
            Assert.IsFalse(criteriaTextBox.Enabled);
        }

        private void AssertAllControlsWereCreated(BusinessObjectLookupListControl businessObjectLookupListControl)
        {
            Control boPanel = businessObjectLookupListControl.Controls[0];
            int pos = 0;
            TestUtilsShared.AssertIsInstanceOf<ILabel>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<IComboBox>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<IPanel>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<ILabel>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<ExtendedTextBoxWin>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<IPanel>(boPanel.Controls[pos++]);

            TestUtilsShared.AssertIsInstanceOf<ILabel>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<ITextBox>(boPanel.Controls[pos++]);
            TestUtilsShared.AssertIsInstanceOf<IPanel>(boPanel.Controls[pos++]);
        }

        [Ignore("No Sort Property any longer")]
        [Test]
        public void Test_ClassPropUpdated_WhenClassSelected_ShouldLoadSelectedClassPropertiesForSortProperty()
        {
            //---------------Set up test pack-------------------
            TestUtilsDMClass.CreateSavedDMClass();
            DMClass validDMClass = TestUtilsDMClass.CreateSavedDMClass();
            TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass);
            TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass);
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            TestUtilsDMClass.CreateSavedDMClass();
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Assert Precondition----------------
            DMLookupList lookupList = businessObjectLookupListControl.LookupList;
            Assert.IsNotNull(lookupList);
            DMLookupListBusinessObject lookupListBusinessObject = TestUtilsShared.AssertIsInstanceOf<DMLookupListBusinessObject>(lookupList);
            //---------------Execute Test ----------------------
            lookupListBusinessObject.DMClass = validDMClass;
            //---------------Test Result -----------------------
            Assert.IsNotNull(lookupListBusinessObject.DMClass);
            Assert.AreSame(validDMClass, lookupListBusinessObject.DMClass);
            PanelInfo.FieldInfo fieldInfo = businessObjectLookupListControl.PanelInfo.FieldInfos["SortPropertyID"];
            IComboBox sortPropertyCombo = (IComboBox)fieldInfo.InputControl;
            Assert.AreEqual(3, sortPropertyCombo.Items.Count);
        }

        [Ignore("No Sort Property any longer")]
        [Test]
        public void Test_ClassPropUpdated_WhenNullClassSelected_ShouldClearSortPropertyCombo()
        {
            //---------------Set up test pack-------------------
            TestUtilsDMClass.CreateSavedDMClass();
            DMClass validDMClass = TestUtilsDMClass.CreateSavedDMClass();
            TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass);
            TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass);
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            TestUtilsDMClass.CreateSavedDMClass();
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            businessObjectLookupListControl.Property = dmProperty;
            DMLookupList lookupList = businessObjectLookupListControl.LookupList;
            DMLookupListBusinessObject lookupListBusinessObject = TestUtilsShared.AssertIsInstanceOf<DMLookupListBusinessObject>(lookupList);
            lookupListBusinessObject.DMClass = validDMClass;
            PanelInfo.FieldInfo fieldInfo = businessObjectLookupListControl.PanelInfo.FieldInfos["SortPropertyID"];
            IComboBox sortPropertyCombo = (IComboBox)fieldInfo.InputControl;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(lookupListBusinessObject.DMClass);
            Assert.AreSame(validDMClass, lookupListBusinessObject.DMClass);
            Assert.AreEqual(3, sortPropertyCombo.Items.Count);
            //---------------Execute Test ----------------------
            lookupListBusinessObject.DMClass = null;
            //---------------Test Result -----------------------
            Assert.IsNull(lookupListBusinessObject.DMClass);
            Assert.AreEqual(1, sortPropertyCombo.Items.Count);
        }

        //[Test]
        //public void Test_SortComboBox_WhenClassSelected_ShouldLoadAllPropertiesInSortComboBox()
        //{
        //    //---------------Set up test pack-------------------
        //    TestUtilsDMClass.CreateSavedDMClass();
        //    DMClass validDMClass = TestUtilsDMClass.CreateSavedDMClass();
        //    TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass).Save();
        //    TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass).Save();
        //    TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass).Save();
        //    TestUtilsDMClass.CreateSavedDMClass();
        //    BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
        //    IBOComboBoxSelector classSelector = businessObjectLookupListControl.ClassSelector;
        //    IBOComboBoxSelector sortComboBox = businessObjectLookupListControl.SortPropertySelector;
        //    //---------------Assert Precondition----------------
        //    Assert.IsNotNull(classSelector);
        //    //---------------Execute Test ----------------------
        //    classSelector.SelectedBusinessObject = validDMClass;
        //    //---------------Test Result -----------------------
        //    Assert.IsTrue(sortComboBox.Enabled);
        //    Assert.AreSame(validDMClass.Properties,sortComboBox.BusinessObjectCollection);
        //}

        //[Test]
        //public void Test_SortComboBox_WhenPropertySelected_ShouldEnableAscendingCheckBoxAndMustBeChecked()
        //{
        //    //---------------Set up test pack-------------------
        //    TestUtilsDMClass.CreateSavedDMClass();
        //    DMClass validDMClass = TestUtilsDMClass.CreateSavedDMClass();
        //    TestUtilsDMClass.CreateSavedDMClass();
        //    TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass).Save();
        //    TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass).Save();
        //    DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty(validDMClass);
        //    dmProperty.Save();
        //    BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
        //    IBOComboBoxSelector classSelector = businessObjectLookupListControl.ClassSelector;
        //    IBOComboBoxSelector sortComboBox = businessObjectLookupListControl.SortPropertySelector;
        //    //---------------Assert Precondition----------------
        //    Assert.IsNotNull(classSelector);
        //    Assert.IsNotNull(sortComboBox);
        //    Assert.AreEqual(3, validDMClass.Properties.Count);
        //    //---------------Execute Test ----------------------
        //    sortComboBox.SelectedBusinessObject = dmProperty;
        //    //---------------Test Result -----------------------
        //    Assert.IsTrue(businessObjectLookupListControl.AscendingCheckBox.Enabled);
        //}
        
        [Test]
        public void Test_Layout()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            //---------------Test Result -----------------------
            Assert.AreEqual(1, businessObjectLookupListControl.Controls.Count);
            //AssertIsInstanceOf<IBOComboBoxSelector>(businessObjectLookupListControl.Controls[0]);
            //AssertIsInstanceOf<IBOComboBoxSelector>(businessObjectLookupListControl.Controls[1]);
            //AssertIsInstanceOf<ICheckBox>(businessObjectLookupListControl.Controls[2]);
            //AssertIsInstanceOf<ITextBox>(businessObjectLookupListControl.Controls[3]);
            //Assert.AreEqual(3, listItemsGridControl.Grid.Columns.Count); //First Column is the ID Column
            //Assert.AreEqual("Display", listItemsGridControl.Grid.Columns[1].HeaderText);
            //Assert.AreEqual("Value", listItemsGridControl.Grid.Columns[2].HeaderText);
        }
        
        [Test]
        public void Test_LookupTypeName_ShouldReturn_BusinessObject()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            const string actual = "Business Object";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string lookupTypeName = businessObjectLookupListControl.LookupTypeName;
            //---------------Test Result -----------------------
            Assert.AreEqual(lookupTypeName, actual);
        }

        [Test]
        public void Test_Property_GetAndSet()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            //---------------Assert Precondition----------------
            Assert.IsNull(businessObjectLookupListControl.Property);
            //---------------Execute Test ----------------------
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Test Result -----------------------
            Assert.IsNotNull(businessObjectLookupListControl.Property);
            Assert.AreEqual(dmProperty, businessObjectLookupListControl.Property);
        }

        [Test]
        public void Test_Property_WhenSet_WithMatchingLookupListType_ShouldUseDmPropLookupList()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMLookupListBusinessObject dmLookupListBO = TestUtilsDMBusinessObjectLookupList.CreateSavedDMBusinessObjectLookupList();
            dmProperty.LookupList = dmLookupListBO;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Test Result -----------------------
            DMLookupList dmLookupList = businessObjectLookupListControl.LookupList;
            Assert.IsInstanceOf(typeof(DMLookupListBusinessObject), dmLookupList);
            Assert.AreEqual(dmProperty.LookupList, dmLookupList);
        }

        [Test]
        public void Test_Property_WhenSet_WithOtherLookupListType_ShouldCreateNewLookupList()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.LookupList = TestUtilsDMDatabaseLookupList.CreateUnsavedValidDMDatabaseLookupList();
            //---------------Assert Precondition----------------
            //---------------Execute Test ---------------------
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Test Result -----------------------
            DMLookupList dmLookupList = businessObjectLookupListControl.LookupList;
            Assert.AreNotSame(dmProperty.LookupList, dmLookupList);
            Assert.IsInstanceOf(typeof(DMLookupListBusinessObject), dmLookupList);
        }

        [Test]
        public void Test_Property_WhenSetWithOtherLookupListType_ThenSetWithOtherLookupListType_ShouldCreateNewLookupList()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMProperty dmProperty2 = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.LookupList = TestUtilsDMDatabaseLookupList.CreateUnsavedValidDMDatabaseLookupList();
            businessObjectLookupListControl.Property = dmProperty;
            DMLookupList dmLookupList = businessObjectLookupListControl.LookupList;
            //---------------Assert Precondition----------------
            Assert.AreNotSame(dmProperty.LookupList, dmLookupList);
            Assert.IsInstanceOf(typeof(DMLookupListBusinessObject), dmLookupList);
            //---------------Execute Test ---------------------
            businessObjectLookupListControl.Property = dmProperty2;
            //---------------Test Result -----------------------
            DMLookupList dmLookupList2 = businessObjectLookupListControl.LookupList;
            Assert.AreNotSame(dmProperty2.LookupList, dmLookupList2);
            Assert.AreNotSame(dmLookupList, dmLookupList2);
            Assert.IsInstanceOf(typeof(DMLookupListBusinessObject), dmLookupList2);
        }

        [Test]
        public void Test_Property_WhenSetWithOtherLookupListType_ThenSetWithMatchingLookupListType_ShouldUseSecondDMPropLookupList()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMProperty dmProperty2 = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMLookupListBusinessObject dmLookupListBO = TestUtilsDMBusinessObjectLookupList.CreateSavedDMBusinessObjectLookupList();
            dmProperty2.LookupList = dmLookupListBO;
            businessObjectLookupListControl.Property = dmProperty;
            DMLookupList dmLookupList = businessObjectLookupListControl.LookupList;
            //---------------Assert Precondition----------------
            Assert.AreNotSame(dmProperty.LookupList, dmLookupList);
            Assert.IsInstanceOf(typeof(DMLookupListBusinessObject), dmLookupList);
            //---------------Execute Test ---------------------
            businessObjectLookupListControl.Property = dmProperty2;
            //---------------Test Result -----------------------
            DMLookupList dmLookupList2 = businessObjectLookupListControl.LookupList;
            Assert.AreSame(dmProperty2.LookupList, dmLookupList2);
            Assert.AreNotSame(dmLookupList, dmLookupList2);
            Assert.IsInstanceOf(typeof(DMLookupListBusinessObject), dmLookupList2);
        }

        [Test]
        public void Test_Property_WhenSetToNull_ShouldDisableControlsAndHaveNullLookupList()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Assert Precondition----------------
            IPanel panel = TestUtilsShared.AssertIsInstanceOf<IPanel>(businessObjectLookupListControl.Controls[0]);
            Assert.AreSame(dmProperty, businessObjectLookupListControl.Property);
            Assert.IsTrue(panel.Enabled);
            //---------------Execute Test ----------------------
            businessObjectLookupListControl.Property = null;
            //---------------Test Result -----------------------
            Assert.IsNull(businessObjectLookupListControl.Property);
            Assert.IsNull(businessObjectLookupListControl.LookupList);
            Assert.IsFalse(panel.Enabled);
        }

        [Test]
        public void Test_Property_WhenSet_ShouldCreateNewSortOrder_WhenNoExistingSortOrderForLookupList()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.LookupList = new DMLookupListBusinessObject();
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dmProperty.LookupList);
            Assert.IsNull(((DMLookupListBusinessObject)dmProperty.LookupList).DMSortOrder);
            //---------------Execute Test ----------------------
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Test Result -----------------------
            Assert.AreSame(dmProperty, businessObjectLookupListControl.Property);
            Assert.IsNotNull(((DMLookupListBusinessObject)dmProperty.LookupList).DMSortOrder);
        }

        [Test]
        public void Test_BusinessObject_WhenSet_ShouldNotCreateNewSortOrder_WhenHasExistingSortOrder()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMSortOrder dmSortOrder = new DMSortOrder();
            DMLookupListBusinessObject dmLookupList = new DMLookupListBusinessObject();
            dmProperty.LookupList = dmLookupList;
            dmLookupList.DMSortOrder = dmSortOrder;
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dmLookupList.DMSortOrder);
            //---------------Execute Test ----------------------
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Test Result -----------------------
            Assert.AreSame(dmProperty, businessObjectLookupListControl.Property);
            Assert.AreSame(dmSortOrder, dmLookupList.DMSortOrder);
        }

        [Test]
        public void Test_WhenAddNewClass_ShouldBeAddedToClassCombo()
        {
            //---------------Set up test pack-------------------
            BusinessObjectLookupListControl businessObjectLookupListControl = new BusinessObjectLookupListControl(CreateControlFactory());
            DMProperty dmProperty = TestUtilsShared.CreateUnsavedValidDMProperty();
            DMAssembly assembly = dmProperty.Class.Assembly;
            businessObjectLookupListControl.Property = dmProperty;
            DMClass dmClass = TestUtilsShared.CreateSavedDMClass(assembly);
            //---------------Assert Precondition----------------
            Dictionary<string, string> lookupList = businessObjectLookupListControl.ClassComboBoxMapper.LookupList;
            Assert.AreEqual(1, lookupList.Count);
            Assert.IsFalse(lookupList.ContainsKey(dmClass.ID.ToString()));
            //---------------Execute Test ----------------------
            businessObjectLookupListControl.Property = dmProperty;
            //---------------Test Result -----------------------
            lookupList = businessObjectLookupListControl.ClassComboBoxMapper.LookupList;
            Assert.AreEqual(2, lookupList.Count);
            Assert.IsTrue(lookupList.ContainsValue(dmClass.ID.ToString()));
            Assert.IsTrue(lookupList.ContainsKey(dmClass.ToString()));
        }

        // - Should display UIPanel with the correct fields
        // - When the DM Prop is set:
        //    - if the DmProp.LookupList is of the same type, then the control should return this LUL for the LookupList Property
        //    - if the DmProp.LookupList is of a different type, then the control should return a new LUL for the LookupList Property
        //    - SubClass combo must load all classes.
        //    - Need blank item for SortBy ComboBox.
        //    - Clear SortBy combo when SubClass combo changed.
        //    - SortBy ComboBox should have all properties for the selected class.
        //    - SortBy ComboBox should be blank/disabled when no class selected.
        //    - Enable Ascending checkbox when SortBy property selected.
        //    - Disable Ascending checkbox if Blank item is selected in the SortBy combo.
        
    }
}
